package com.lizhi.menu.controller;

import com.lizhi.menu.common.response.Result;
import com.lizhi.menu.domain.Notify;
import com.lizhi.menu.service.INotifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * 公告Controller
 * 
 * @author lizhi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/system/notify")
@Api(tags = "公告管理")
public class NotifyController
{
    @Autowired
    private INotifyService notifyService;

    /**
     * 查询公告列表
     */
    @GetMapping("/list")
    @ApiOperation("查询公告列表")
    public Result list(Notify notify)
    {
        
        List<Notify> list = notifyService.selectNotifyList(notify);
        return Result.ok(list);
    }

    /**
     * 获取公告详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取公告详细信息")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.ok(notifyService.selectNotifyById(id));
    }

    /**
     * 新增公告
     */
    @PostMapping
    @ApiOperation("新增公告")
    public Result add(@RequestBody Notify notify)
    {
        return Result.ok(notifyService.insertNotify(notify));
    }

    /**
     * 修改公告
     */
    @PutMapping
    @ApiOperation("修改公告")
    public Result edit(@RequestBody Notify notify)
    {
        return Result.ok(notifyService.updateNotify(notify));
    }

    /**
     * 删除公告
     */
	@DeleteMapping("/{ids}")
    @ApiOperation("删除公告")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.ok(notifyService.deleteNotifyByIds(ids));
    }
}
